import {ExtraOptions, RouterModule, Routes} from '@angular/router';
import {NgModule} from '@angular/core';
import {
  NbAuthComponent,
  NbLogoutComponent,
  NbRegisterComponent,
  NbRequestPasswordComponent,
  NbResetPasswordComponent,
} from '@nebular/auth';
import {SwitchComponent} from "./login/switch.component";
import {LoginComponent} from "./login/login.component";
import {AuthGuard} from "./login/AuthGuard";

const routes: Routes = [
  {
    path: 'pages',
    loadChildren: () => import('app/pages/pages.module')
      .then(m => m.PagesModule),
  },
  {
    path:'ylqq',
    canActivate:[AuthGuard],
    loadChildren:()=>import('./ylqq/ylqq.module').then(m=>m.YLQQModule)
  },
  {
    path:'ylhq',
    canActivate:[AuthGuard],
    loadChildren:()=>import('./ylhq/ylhq.module').then(m=>m.YLHQModule)
  },
  {
    path: 'auth',
    component: NbAuthComponent,
    children: [
      {
        path: '',
        component: LoginComponent,
      },
      {
        path: 'login',
        component: LoginComponent,
      },
      {
        path: 'login/:action',
        component: LoginComponent,
      },
      {
        path: 'request-password',
        component: NbRequestPasswordComponent,
      },
      {
        path: 'reset-password',
        component: NbResetPasswordComponent,
      }
    ],
  },
  {
    path:'switch',
    canActivate:[AuthGuard],
    component:SwitchComponent
  },
  { path: '', redirectTo: '/switch', pathMatch: 'full' },
  { path: '**', redirectTo: '/switch' },
];

const config: ExtraOptions = {
  useHash: false,
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}
